/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package guiPlaylisted.view;

import controlPlaylisted.MusicController;

import dataPlaylisted.Music;

import guiPlaylisted.PlaylistedApp;
import java.io.FileNotFoundException;
import java.io.IOException;

import java.util.ArrayList;

import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 *
 * @author Administrador
 */

public class MusicView {

    private ArrayList<Music> m_musicList;

    private MusicController m_musicController;

    private JDialog m_musicData;
    private JDialog m_dlgMusicList;

    private static MusicView instance;

    public MusicView() throws FileNotFoundException, IOException, ClassNotFoundException{
         m_musicController = MusicController.getInstance();
         m_musicList = m_musicController.getMusicList();
    }

    public static MusicView getInstance() throws FileNotFoundException, IOException, ClassNotFoundException{
        if(instance == null)
            instance = new MusicView();
        return instance;
    }

    public void saveMusicData(String _nameTrack, String _nameArtist, String _whell, String _style) throws FileNotFoundException, ClassNotFoundException, IOException{
            m_musicController.setMusicOnList(_nameTrack, _nameArtist, _whell, _style);
    }

    public void runMusicData() throws FileNotFoundException, IOException, ClassNotFoundException{
        JFrame mainFrame = PlaylistedApp.getApplication().getMainFrame();
        m_musicData = new guiCadastroMusica(mainFrame,true);
        m_musicData.setLocationRelativeTo(mainFrame);
        PlaylistedApp.getApplication().show(m_musicData);
    }

    public void runMusicList() throws FileNotFoundException, IOException, ClassNotFoundException{
        JFrame mainFrame = PlaylistedApp.getApplication().getMainFrame();
        m_dlgMusicList = new guiMusicList(mainFrame,true);
        m_dlgMusicList.setLocationRelativeTo(mainFrame);
        PlaylistedApp.getApplication().show(m_dlgMusicList);
    }

    public ArrayList<String> getStyles(){
        return m_musicController.getStyleList();
    }


    public ArrayList<String> getWhell(){
        return m_musicController.getCammelotList();
    }

    public ArrayList<Music> getMusicList(){
        return m_musicList;
    }
}
